css: Fail animation shorthand parsing properly
authorBenjamin Otte <otte@redhat.com>
Wed, 30 Jul 2014 16:45:15 +0000 (18:45 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 31 Jul 2014 08:03:19 +0000 (10:03 +0200)
When a number is not a nubmer, don't just crash, exit properly with an
error code.

See attached testcase for an example.

gtk/gtkcssshorthandpropertyimpl.c
testsuite/css/parser/Makefile.am
testsuite/css/parser/animation-crash-3.12.css [new file with mode: 0644]
testsuite/css/parser/animation-crash-3.12.errors [new file with mode: 0644]
testsuite/css/parser/animation-crash-3.12.ref.css [new file with mode: 0644]

index c81e2c470330ce71b7bded2e3b97eadb6e8cab06..647787880cf28656faeeae81229032b4fe7bae97 100644 (file)
@@ -722,6 +722,9 @@ parse_one_animation (GtkCssShorthandProperty  *shorthand,
                                                GTK_CSS_POSITIVE_ONLY
                                                | (values[1] == NULL ? GTK_CSS_PARSE_NUMBER : 0)
                                                | (values[3] == NULL ? GTK_CSS_PARSE_TIME : 0));
+          if (value == NULL)
+            return FALSE;
+
           if (_gtk_css_number_value_get_unit (value) == GTK_CSS_NUMBER)
             values[1] = value;
           else if (values[2] == NULL)
index f44f7757dc3131798600b6448ffcd5cf7d75fa58..4c35afeecf0f2f64e6631f597e3d6192ba4f5afc 100644 (file)
@@ -30,6 +30,9 @@ clean-local:
        rm $(builddir)/*.out.css || true
 
 test_data = \
+       animation-crash-3.12.css \
+       animation-crash-3.12.errors \
+       animation-crash-3.12.ref.css \
        animation-shorthand-crash.css \
        animation-shorthand-crash.ref.css \
        at-invalid-01.css \
diff --git a/testsuite/css/parser/animation-crash-3.12.css b/testsuite/css/parser/animation-crash-3.12.css
new file mode 100644 (file)
index 0000000..c9f4506
--- /dev/null
@@ -0,0 +1,3 @@
+* {
+  animation: 2gra;
+}
diff --git a/testsuite/css/parser/animation-crash-3.12.errors b/testsuite/css/parser/animation-crash-3.12.errors
new file mode 100644 (file)
index 0000000..8c9ecc4
--- /dev/null
@@ -0,0 +1 @@
+animation-crash-3.12.css:2: error: GTK_CSS_PROVIDER_ERROR_SYNTAX
diff --git a/testsuite/css/parser/animation-crash-3.12.ref.css b/testsuite/css/parser/animation-crash-3.12.ref.css
new file mode 100644 (file)
index 0000000..e69de29